import requests
from config import url, headers_web,headers_wechat

class ClassActivity:
    def __init__(self):
        self.url = url
        self.headers = headers_web

    @classmethod
    def get_all_activity_type(cls,url_path:str,params=None,headers=headers_web):
        """
        @Summary:获取所有的活动类型接口
        @Description:云课堂 管理端 管理员获取所有的活动类型接口
        :param url_path:/teachingApi/api/v1/activitymaterial/activitytypelist
        :param params:validCode:验证码（&signKey=123123）
        :param headers:
        :return:[{
                    'classActivityTypeIndex':'',#活动类型Index
                    'classActivityTypeName':''#活动类型名称
                    }]
        """

        url_path = url_path + "/teachingApi/api/v1/activitymaterial/activitytypelist"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_all_activity_type_on_teacher(cls,url_path:str,params=None,headers=headers_web):
        """
        @Summary:获取活动类型接口
        @Description:web老师端
        :param url_path:/teachingApi/classactivity/classactivitytypelist
        :param params:validCode:验证码（&signKey=123123）
        :param headers:
        :return:[{
                    'classActivityTypeIndex':'',#活动类型Index
                    'classActivityTypeName':''#活动类型名称
                    }]
        """
        url_path = url_path + "/teachingApi/classactivity/classactivitytypelist"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def post_attendances_activity(cls,url_path:str,params=None,headers=headers_web,json=None):
        """
        @Summary:查询考勤活动信息
        @Description:教学中心管理端
        :param url_path:/teachingApi/v1/attendanceactivity/attendances
        :param params:validCode:验证码（&signKey=123123）
        :param headers:
        :param json:body:{
                            'collegeId':'',#学院Id
                            'courseName':'',#课程名称
                            'endTime':'',#结束时间
                            'page':'',#当前页
                            'pageSize':'',#每页个数
                            'startTime':'',#开始时间
                            'studentType':'',#课程开课类型 0：本科生 1：研究生
                            'teacherNameOrNo':'',#教师名称或工号
                            'whetherEffective':'',#是否有效
                            'whetherExportDetail':''#是否导出详情
                            }
        :return:activity
        """
        url_path = url_path + "/teachingApi/v1/attendanceactivity/attendances"
        r = requests.post(url=url_path, headers=headers, params=params,json=json)
        return r

    @classmethod
    def post_export_attendance_activity(cls,url_path:str,params=None,headers=headers_web,json=None):
        """
        @Summary:导出考勤活动信息
        @Description:教学中心管理端
        :param url_path:
        :param params:validCode:验证码（&signKey=123123）
        :param headers:
        :param json:body:{
                            'collegeId':'',#学院Id
                            'courseName':'',#课程名称
                            'endTime':'',#结束时间
                            'page':'',#当前页
                            'pageSize':'',#每页个数
                            'startTime':'',#开始时间
                            'studentType':'',#课程开课类型 0：本科生 1：研究生
                            'teacherNameOrNo':'',#教师名称或工号
                            'whetherEffective':'',#是否有效
                            'whetherExportDetail':''#是否导出详情
                            }
        :return:success
        """
        url_path = url_path + "/teachingApi/v1/attendanceactivity/exportattendances"
        r = requests.post(url=url_path, headers=headers, params=params, json=json)
        return r

    @classmethod
    def get_class_activity_list(cls,url_path:str,params=None,headers=headers_web):
        """
        @Summary:获取活动列表信息
        @Description:web老师端获取活动列表信息
        :param url_path:/teachingApi/v1/classactivity
        :param params:{
                        'classTimesNum':'',#课次
                        'courseId':'',#课程id
                        'groupIds':'',#组ids
                        'schoolYear':'',#学年
                        'term':'',#学期
                        'validCode':''#验证码（courseId=?&signKey=123123）
                        }
        :param headers:
        :return:
        """
        url_path = url_path + "/teachingApi/v1/classactivity"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def get_course_segment_activity(cls,url_path:str,params=None,headers=headers_web):
        """
        @Summary:编写获取课程节次课堂活动相关数据接口
        @Description:web老师端
        :param url_path:/teachingApi/v1/classactivity/coursesegmentactivitys
        :param params:{
                        'courseTableDetailId':'',#课表id
                        'segments':'',#节次时间（多个逗号拼接）
                        'validCode':'',#验证码（&signKey=123123）
                        }
        :param headers:
        :return:[{
                    'activityTypeId':'',#课次
                    'activityTypeName':'',#课程id
                    'endRestActivityTime':'',#组ids
                    'startRestActivityTime':'',#学年
                    }]
        """
        url_path = url_path + "/teachingApi/v1/classactivity/coursesegmentactivitys"
        r = requests.get(url=url_path, headers=headers, params=params)
        return r

    @classmethod
    def post_class_activity_on_type(cls,url_path:str,params=None,headers=headers_web,json=None,paramspath=None):
        """
        @Summary:按照活动类型获取课堂活动
        @Description:web老师端
        :param url_path:/teachingApi/v1/classactivity/{courseId}/classactivitybytype
        :param params:validCode:验证码（courseId=?&signKey=123123）
        :param headers:
        :param json:{
                        'activityTypeIndex':'',#活动类型Index
                        'groupIds':'',#组ids，多个","拼接
                        'page':'',#当前页
                        'pageSize':'',#每页个数
                        'queryParameter':'',#模糊查询字符串
                        'schoolYear':'',#学年
                        'term':''#学期
                    }
        :param paramspath:courseId:课程id
        :return:activity
        """
        url_path = url_path + "/teachingApi/v1/classactivity/{}/classactivitybytype".format(paramspath)
        r = requests.post(url=url_path, headers=headers, params=params,json=json)
        return r

    @classmethod
    def get_course_class_timelist(cls,url_path:str,params=None,headers=headers_web):
        """
        @Summary:接口-获取课堂活动课次信息
        @Description:web老师端
        :param url_path:/teachingApi/v1/teachercourseclasstimelist
        :param params:{
                        'courseId':'',#课程id
                        'groupIds':'',#组ids，多个","拼接
                        'validCode':'',#courseId=?&signKey=123123(md5加密)
                        'platformSource':'',#平台来源(老师端：null或0,学生端：1)
                        'schoolYear':'',#学年
                        'term':''#学期
                    }
        :param headers:
        :return:
        """
        url_path = url_path + "/teachingApi/v1/teachercourseclasstimelist"
        r = requests.post(url=url_path, headers=headers, params=params)
        return r